home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7565 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  8.5 KB

  1. Path: news1.cris.com!Crawford
  2. From: Crawford@cris.com (CRAWFORD)
  3. Newsgroups: comp.lang.pl1,comp.lang.c
  4. Subject: Re: PL/I and C
  5. Date: 27 Feb 1996 14:13:49 GMT
  6. Organization: Concentric Internet Services
  7. Message-ID: <4gv3it$9cf@spectator.cris.com>
  8. References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <4gn5d8$t5f@newsbf02.news.aol.com> <4gril3$sn9@goanna.cs.rmit.EDU.AU> <31320777.2810@corp.dialog.com>
  9. Reply-To: crawford@iac.net
  10. NNTP-Posting-Host: mariner.cris.com
  11.  
  12. Paul Gorodyansky <paul_gorodyansky@corp.dialog.com> writes:
  13.  
  14. >So, I'll be more careful and post only to a specific group, because
  15. >OUR talk was about *mainframe* C vs. PL/I, and MOREOVER, about
  16. >*business* applications, involving heavy Text Processing, not about
  17. >*systems* programming.                   ---------------
  18.  
  19.     Ahem, I do business programming that's _all_ text processing,
  20. and I do it in C. I've never had problems with C being "restricted" in
  21. any way, though I would like to hunt up some regexp code to make life
  22. easier.
  23.  
  24.     I'll grant that these applications are being written on a UNIX
  25. platform, interfacing with an RDBMS, so it's not exactly like doing
  26. mainframe flat-file work. But... I spent six months doing PL/I
  27. programming on our mainframe, and I can say this:
  28.  
  29.     Gimmee C _anyday_.
  30.  
  31. > Again, in *business* applications *Production* environment, where 
  32. >   - to be 'closer to Specs',
  33. >   - to be 'easy to read' and
  34. >   - 'easy to maintain' 
  35. >   - 'quicker to fix'
  36. > is Vital, PL/I is MUCH better than C.
  37.  
  38.     All of those factors depend more on structure and design than
  39. on the language, IMHO. I was once handed a PL/I program that in no way
  40. resembled the specs, was a twisted mess of spaghetti code, and took me
  41. a week to figure out. My assignment was to sort the output, so that
  42. the end-of-job report was in state order. I had been using PL/I for
  43. about three months, so I had to pull out the reference book to figure
  44. out procedure calls. I wrote two procedures to handle the sorting and
  45. sorted printing, then "untwisted" as much code as I could.
  46.  
  47.     The problem wasn't the language, but the utter lack of design
  48. and structure to the code. You can write well-structured,
  49. easy-to-follow code in ALC, APL, or anything. You can write complete
  50. crap in _any_ language.
  51.  
  52. >   All you, C guys who replied, paid TOO MUCH attention to my note
  53. >about UNIONS, but it's a MINOR thing compared to other AWFUL for
  54. >an *application* programmer  things in C that I listed.
  55. >In systems/low-level tasks C may be Perfect.
  56.  
  57.     As an *application* _and_ "systems/low-level" programmer, I
  58. find C an adequate and useful tool. While I've occasionally found
  59. tasks which would be better handled with other languages, I work for a
  60. "One True Language" shop, and C is all we have for UNIX. C does the
  61. job, and does it well. Design and structure are the key.
  62.  
  63. >After so many replies that did not quote these MAJOR things, I am
  64. >posting to comp.lang.C group LAST time, repeating the items, that,
  65. >in my opinion, make C a *bad* choice for
  66. >  an *application* Production environment,
  67. >  where Fix time is *critical*,
  68. >  where are MANY (not ONE package for market) *different* programs,
  69. >  OFTEN to be changed due to Specs changes,
  70. >  often by several engineers, who may see *this* program and
  71. >  *this* data(Huge) FIRST time and have COUPLE hours to fix it.
  72.  
  73.     Bull. I can fix one of my C functions in less time than it
  74. takes the mainframe programmers to decide if they have a problem. It's
  75. a matter of organization. Our system consists of a few dozen programs,
  76. a 120 Gig database, and literally millions of transactions. C gets the
  77. job done -- well.
  78.  
  79. >   BUT 'there is no free lunch' and this effectiveness causes
  80. >LESS readability.  
  81. >PL/I is reacher, so it's is easier to implement things there and
  82. >make a code more readable.
  83.  
  84.     I have to disagree. The readibility of any code is a result of
  85. structure, the familiarity of the reader with the language, and the
  86. design of the program. I find it _much_ easier to understand what's
  87. happening when a function named "binary_search" is called, than
  88. if the programmer cut and paste the code for a binary search. That can
  89. happen in any language.
  90.  
  91. >Select;                                                         
  92. >  When ( SUBSTR(INREC,4,1) = ' ' ) 
  93.  
  94. if (inrec[4] == ' ')
  95.     {
  96.     };
  97.  
  98.     Bad example. :-)
  99.  
  100. >       ....                                                           
  101. >  When
  102. >       ...
  103. >  When ( INDEX(UPALPHA,Cur_Tag) > 0  &                           
  104. >         VERIFY(W_TAG23,'0123456789') = 0 )                     
  105.  
  106. if (strstr (UPALPHA, Cur_Tag) != NULL)
  107.     if (!verify_string (WTAG23, "0123456789"))
  108.         {
  109.         };
  110.  
  111.     Where verify_string is some function that returns zero if all
  112. characters in arg1 are contained with arg2. We've implemented
  113. this function where I work; it's quite possible.
  114.  
  115. >  When ( String_1 || String_2 = String_3 )
  116.  
  117. if ((!strcmp (String_1, String_3)) || (!strcmp (String_2, String_3)))
  118.     {
  119.     };
  120.  
  121. >It is how SPECIFICATIONS look like, so for a person who works 
  122. >with this program  FIRST time, it is CLEAR, after reading specs,
  123. >what this part of code is doing.
  124. >     Just TRY to implement it in C !!!
  125. >You will HAVE TO find some 'work around', so it will be further
  126. >                                                        ------ 
  127. >from specs and the piece of the code will be much BIGGER and LESS 
  128. >clear, harder to understand.
  129.  
  130.     Clue: I always put comments in the code that point back to the
  131. specs. My first step in writing the code is to block out the flow of
  132. the code with comments. I fill in the functionality later, leaving in
  133. comments that refer back to the specs.
  134.  
  135. >   C has this VERY STUPID limitation - a 'string' in C it's a set of
  136. >bytes with x'00' at the end ! 
  137. >But, we have x'00' all over our source data !
  138. >For example, we have on-line European Patent Office data (only ONE of
  139. >our 400+ *different* applications), and source file is 40 gigabytes (!)
  140. >FULL of x'00' !!!
  141.  
  142.     This is called a convention. You can use memcmp, memcpy, etc.
  143. to work with arbitrary byte arrays. 
  144.  
  145. >    Also, C does not have Variable Length Strings, that are VERY
  146. >important for our *application* programs. Again, this feature helps to
  147. >have programs SHORTER, more READABLE, and CLOSER to specs.
  148.  
  149.     ??
  150.     The entire idea behind NUL-delimited strings is to allow
  151. arbitrary-length strings. The idea was that few people would have need
  152. for NUL's in their data, and those who did could use the mem*
  153. functions.
  154.  
  155.     I'd love to know what those NUL's are denoting in your data.
  156. Could their purpose be better served with spaces, '0's, or the like?
  157. If they're packed decimal, well, I'm not sure what IBM's done to
  158. support packed decimal under C. It's possible that your problem comes
  159. from having to deal data standard C wasn't really aimed at.
  160.  
  161. >    And now imagine how IT (foo-o-o) looks in OUR programs, where
  162. >due to this STUPID x'00' limitation, we even can not use THESE
  163. >(not very friendly) functions, and MUST use operations on
  164. >BUFFERS, i.e. mem.. functions, taking through a code Length of
  165. >buffers all the time ! 
  166.  
  167.     ??
  168.     Not very friendly? How could anything be more friendly than
  169. strtok? :-)
  170.  
  171. >   Same Program in PL/I is 100 times more readable and is 100 times
  172. >more easy to CHANGE and FIX.
  173.  
  174. >So, my points are the following.
  175. >  Open Systems people very often tell that *only* C
  176. >should be used EVERYWHERE, and it's wrong 
  177.  
  178.     I agree. You wouldn't use a chef's knife for everything.
  179. Sometimes you need to pull out the cleaver, the paring knife, or
  180. whatever. The real requirement is that they have to be sharp and _you
  181. have to know how to use them_.
  182.  
  183. >   For *application* programming *Production* environment with a lot 
  184. >of Text Processing, and a lot of *different* and often *changed* 
  185. >   ---------------                               -----
  186. >programs, PL/I is MUCH, MUCH better than C:             
  187.  
  188.     I don't agree. I've been able to change C programs much faster
  189. and easier than I've seen PL/I programs change. The difference was
  190. design, not the language.
  191.  
  192. > - PL/I has wider set of statements, so it is much easier in PL/I
  193. >   to make a code be CLOSE to specs, so next person will understand
  194. >   a code faster and can FIX program faster;
  195.  
  196.     A "wider set of statements" can be a disadvantage,
  197. specifically in terms of readibility.
  198.  
  199. > - if a language REQUIRES workaround OFTEN, then it is LESS readable 
  200. >   than another language that is reacher.
  201.  
  202.     "Reacher?" I'll assume you mean "richer".
  203.  
  204.     True. But C is as rich as you make it. You need a library that
  205. works on "strings" containing NULs? Write or buy one.
  206.  
  207. --
  208. "They sentenced me to twenty years of boredom, for trying to change
  209. the system from within."
  210. Robert Crawford                crawford@iac.net
  211. http://www.iac.net/~crawford
  212.